Before working on this assignment please read these instructions fully. In the submission area, you will notice that you can click the link to Preview the Grading for each step of the assignment. This is the criteria that will be used for peer grading. Please familiarize yourself with the criteria before beginning the assignment.
This assignment requires that you to find at least two datasets on the web which are related, and that you visualize these datasets to answer a question with the broad topic of economic activity or measures (see below) for the region of Ann Arbor, Michigan, United States, or United States more broadly.
You can merge these datasets with data from different regions if you like! For instance, you might want to compare Ann Arbor, Michigan, United States to Ann Arbor, USA. In that case at least one source file must be about Ann Arbor, Michigan, United States.
You are welcome to choose datasets at your discretion, but keep in mind they will be shared with your peers, so choose appropriate datasets. Sensitive, confidential, illicit, and proprietary materials are not good choices for datasets for this assignment. You are welcome to upload datasets of your own as well, and link to them using a third party repository such as github, bitbucket, pastebin, etc. Please be aware of the Coursera terms of service with respect to intellectual property.
Also, you are welcome to preserve data in its original language, but for the purposes of grading you should provide english translations. You are welcome to provide multiple visuals in different languages if you would like!
As this assignment is for the whole course, you must incorporate principles discussed in the first week, such as having as high data-ink ratio (Tufte) and aligning with Cairo’s principles of truth, beauty, function, and insight.
Here are the assignment instructions:
What do we mean by economic activity or measures? For this category you might look at the inputs or outputs to the given economy, or major changes in the economy compared to other regions.
Looking for an example? Here's what our course assistant put together for the Ann Arbor, MI, USA area using sports and athletics as the topic. Example Solution File
Question 1.
State the region and the domain category that your data sets are about (e.g., Ann Arbor, Michigan, United States and economic activity or measures).</b>
Ann Arbor, Michigan, United States
Economic activity or measures
Question 2
You must state a question about the domain category and region that you identified as being interesting.</b>
How have the hourly earnings changed by sector over the last 10 years?
Question 3
You must provide at least two links to available datasets. These could be links to files such as CSV or Excel files, or links to websites which might have data in tabular form, such as Wikipedia pages.</b>
Professional and Business Services
Manufacturing, Trade,
Transportation, and Utilities, and
Education and Health Services
https://data.bls.gov/timeseries/LAUMT261146000000005&output_view=data&include_graphs=false (Local Area Unemployment Statistics
)
https://data.bls.gov/timeseries/SMU26114606000000001&output_view=data&include_graphs=false (Professional and Business Services)
https://data.bls.gov/timeseries/SMU26114606500000001&output_view=data&include_graphs=false (Education and Health Services)
https://data.bls.gov/timeseries/SMU26114603000000001&output_view=data&include_graphs=false (Manufacturing)
https://data.bls.gov/timeseries/SMU26114604000000001&output_view=data&include_graphs=false (Trade, Transportation, and Utilities)
Question 4
You must upload an image which addresses the research question you stated. In addition to addressing the question, this visual should follow Cairo's principles of truthfulness, functionality, beauty, and insightfulness.</b>
Ann Arbor Salary AVG.png
Question 5
You must contribute a short (1-2 paragraph) written justification of how your visualization addresses your stated research question.</b>
This chart answers the research question by displaying the hourly earnings average among industry sectors in Ann Arbor, Metro Area, Michigan. The following sectors have been analyzed: Education & Health Services, Trade, Transportation and Utilities, Professional and Business Services, and Manufacturing. The data collected represents the period of ten years, between 2007 and 2017. The series used in this assignment have been gathered from the Bureau of Labor Statistics individually, and data cleaning and processing needed to be performed. Information from several industry sectors is available in a big range of formats for download.
The Professional and Business Services' sector showed the highest variation, especially after 2014. Trade and Education are very close to each other, mainly after 2010, when the Trade sector started to decline and the Education sector average rate started to increase. The Manufacturing sector was the one with the lowest average, declining from the beginning of the data series, and only increased from 2010. Employment data for the same region is also available on that site, which allowed us to correlate these values with each sector. Therefore, we came to a conclusion the sector Professional and Business Services presented strong correlation with employment rate (0.903), meaning the average earnings for this sector has a high tendency to increase as the employment increases.
A line chart has been chosen because it is better for historically disposed data. In order to incorporate Cairo's principles, we have applied some visual concepts to this chart. The labels were softened to avoid user distraction. Also, only the line with the highest average variation had a strong color; the remaining colors have been softened to provide a simple look and feel. Frames, ticks and graph background were removed. Finally, legends were placed appropriately to identify the lines easier.
In [1]:
#Imports
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib notebook
In [2]:
df_employment = pd.read_csv('Week_4_datasets/Unemployment Statistics.csv')
df_manufacturing = pd.read_csv('Week_4_datasets/Manufacturing.csv')
df_transportation = pd.read_csv('Week_4_datasets/Trade and Transportation.csv')
df_professional_services = pd.read_csv('Week_4_datasets/Professional and Business Services.csv')
df_education_and_health = pd.read_excel('Week_4_datasets/SeriesReport-20170327173049_eca63d.xlsx', skiprows=12)
In [4]:
df_education_and_health = df_education_and_health[['Series ID', 'Year', 'Period', 'Value']]
In [5]:
df_employment = df_employment[['Year', 'Period', 'employment']]
In [6]:
df_employment['education_health'] = df_education_and_health['Value']
df_employment['manufacturing'] = df_manufacturing['Value']
df_employment['trade_transportation'] = df_transportation['Value']
df_employment['professional_services'] = df_professional_services['Value']
In [7]:
df_employment.head()
Out[7]:
In [8]:
df_employment_grouped = df_employment.set_index(['Year', 'Period'])
In [9]:
df_employment_grouped.head()
Out[9]:
In [97]:
df_employment[df_employment['Period'] == 'Jan']
Out[97]:
In [10]:
df_employment_grouped['employment'] = df_employment_grouped['employment'].apply(lambda x: x.replace('(P)', ''))
In [11]:
df_employment_grouped['employment'] = df_employment_grouped['employment'].convert_objects(convert_numeric=True)
df_employment_grouped['education_health'] = df_employment_grouped['education_health'].convert_objects(convert_numeric=True)
df_employment_grouped['manufacturing'] = df_employment_grouped['manufacturing'].convert_objects(convert_numeric=True)
df_employment_grouped['trade_transportation'] = df_employment_grouped['trade_transportation'].convert_objects(convert_numeric=True)
df_employment_grouped['professional_services'] = df_employment_grouped['professional_services'].convert_objects(convert_numeric=True)
In [12]:
dates = df_employment[df_employment['Period'] == 'Jan']
In [13]:
df_employment_grouped.corr()
Out[13]:
In [29]:
# professional services have a high tendency to increase as employment rate increases (highest correlation) => 0.903 correlation
In [28]:
plt.figure(figsize=(9,6));
sns.heatmap(df_employment_grouped.corr());
plt.tight_layout()
In [15]:
sns.set_style('white')
In [45]:
plt.figure(figsize=(9,6))
df_employment_grouped['education_health'].plot(label='Education & Health Services',
lw=4, alpha=0.4);
df_employment_grouped['trade_transportation'].plot(label='Trade, Transportation, and Utilities', c='orangered',
lw=4, alpha=0.4);
df_employment_grouped['professional_services'].plot(label='Professional and Business Services', c='green',
lw=4);
df_employment_grouped['manufacturing'].plot(label='Manufacturing', c='navy',
lw=4, alpha=0.4);
plt.xticks(dates['Year'].index, dates['Year'], fontsize=10, alpha=0.7);
plt.xlabel('Period');
plt.ylabel('Average hourly earnings by sector', alpha=0.8);
plt.legend(loc='best');
plt.title('10 Years average hourly earnings by sector in Ann Arbor, MI');
plt.tick_params(top='off', bottom='off', left='off', right='off');
ax = plt.gca()
ax.spines['top'].set_visible(False);
ax.spines['bottom'].set_visible(False);
ax.spines['right'].set_visible(False);
ax.spines['left'].set_visible(False);
In [46]:
plt.figure(figsize=(9,6))
df_employment_grouped['employment'].plot(label='employment',
lw=4, alpha=1);
plt.xticks(dates['Year'].index, dates['Year'], fontsize=10, alpha=0.7);
plt.xlabel('Period');
plt.ylabel('Thousands of people', alpha=0.8);
plt.legend(loc='best');
plt.title('10 Years employment Statistics in Ann Arbor, MI');
plt.tick_params(top='off', bottom='off', left='off', right='off');
ax = plt.gca()
ax.spines['top'].set_visible(False);
ax.spines['bottom'].set_visible(False);
ax.spines['right'].set_visible(False);
ax.spines['left'].set_visible(False);
In [ ]: